<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <div class="header clearfix">
        <nav>
            <ul class="nav nav-pills pull-right">
                <li role="presentation" ><a href="<?php echo Yii::app()->baseUrl; ?>/admin/site">列表</a></li>
                <li role="presentation" <?php if($data['id']==0){ ?>class="active" <?php } ?>><a href="<?php echo Yii::app()->baseUrl; ?>/admin/siteChange">新增</a></li>
            </ul>
        </nav>
        <h3 class="text-muted"><?php echo $data['id']>0?'修改':'新增';?></h3>
    </div>

    <div class="row placeholders">
        <form class="form-horizontal" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="<?php echo $data['id'] ?>">
            <div class="form-group">
                <label for="inputPassword3" class="col-sm-2 control-label">类型</label>
                <div class="col-sm-10">
                    <select class="form-control" name="type_id">

                        <?php if(is_array($type)){
                                foreach($type as $k=>$v){
                                    ?>
                                 <option <?php if($data['type_id']==$v['id']){ ?> selected="selected" <?php } ?> value="<?php echo $v['id'] ?>"><?php echo $v['name'] ?></option>
                                <?php }
                            }?>

                    </select>
                </div>
            </div>

            <!--图片上传-->
            <div class="form-group">
                <label  class="col-sm-2 control-label">图片上传</label>
                <div class="col-sm-10" id="img_box">
                    <input type="file" class="form-control" style="margin-bottom: 15px;" name="imgFile">
                </div>
<!--                <a c href="javascript:;" id="img_ps">添加</a>-->
            </div>
            <?php if($data['id']>0){?>
            <div class="form-group">
                <label  class="col-sm-2 control-label">已上传</label>
                <?php if(is_array($imgs)){
                        foreach($imgs as $a=>$b){
                ?>
                            <div id="img_show_box<?php echo $b['id'] ?>">
                                <input type="hidden" name="del_imgs[]" id="del_img<?php echo $b['id'] ?>">
                                <img src="<?php echo Yii::app()->baseUrl; ?>/<?php echo $b['url'] ?>" class="img-responsive" alt="Responsive image">
                                <a href="javascript:void(0)" onclick="del_img('<?php echo $b['id'] ?>')" >删除</a>
                            </div>

                <?php
                        }
                    }
                ?>

            </div>
            <?php } ?>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-default">提交</button>
                </div>
            </div>
        </form>
    </div>

</div>

<script type="text/javascript">
    $(function(){
        $("#img_ps").click(function(){
            $("#img_box").append('<input type="file" class="form-control" style="margin-bottom: 15px;" name="imgFile[]">')

        })
    });

    function del_img(id){
        $('#img_show_box'+id).hide();
        $('#del_img'+id).val(id);
    }

</script>